
using System;
using System.Linq;
using Csla;
using Csla.Data;
using Csla.Security;
using Csla.Validation;

namespace HousingInfo.Library
{ 
	public partial class CategoryBO : Csla.BusinessBase<CategoryBO>
	{

		#region Authorization Rules
		protected override void AddAuthorizationRules()
		{
			//TODO: Define authorization rules in CategoryBO
			//AuthorizationRules.AllowRead(CategoryIDProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(CategoryNameProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(IsHousingCategoryProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(IsTopicForumProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(IsLanguageProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(IsNewsCategoryProperty, "CategoryBOReadGroup");
			//AuthorizationRules.AllowRead(IsActiveProperty, "CategoryBOReadGroup");

			//AuthorizationRules.AllowWrite(CategoryNameProperty, "CategoryBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsHousingCategoryProperty, "CategoryBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsTopicForumProperty, "CategoryBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsLanguageProperty, "CategoryBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsNewsCategoryProperty, "CategoryBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsActiveProperty, "CategoryBOWriteGroup");
		}

		protected static void AddObjectAuthorizationRules()
		{
			//TODO: Define object-level authorization rules of CategoryBO
			//AuthorizationRules.AllowCreate(typeof(CategoryBO), "CategoryBOCreateGroup"));
			//AuthorizationRules.AllowEdit(typeof(CategoryBO), "CategoryBOEditGroup"));
			//AuthorizationRules.AllowDelete(typeof(CategoryBO), "CategoryBODeleteGroup"));
		}
		#endregion //Authorization Rules
		private void AssignParentKey(HousingInfo.DataLinQ.Category data)
		{
			 //data.ParentId = ReadProperty<ParentBO>(ParentBOProperty).Id;
		}

        //#region Trang Admin - Danh Muc

        //#region Ham Lay danh sach tung danh muc
        //public static CategoryBOList GetCategoryBO_ByType(int category_id, bool isnhadat, bool isdiendan, bool isngonngu, bool istintuc)
        //{
        //    return DataPortal.Fetch<CategoryBOList>(new FilterCriteriaGetCategory_ByType(category_id, isnhadat, isdiendan, isngonngu, istintuc));
        //}
        //#endregion //End ham lay tung loai danh muc

        //#region khai bao tham so
        //private class FilterCriteriaGetCategoryBO_ByType
        //{
        //    int cateid;
        //    public bool nhadat;
        //    public bool diendan;
        //    public bool ngonngu;
        //    public bool tintuc;
        //    public FilterCriteriaGetCategoryBO_ByType(int id, bool nd, bool dd, bool nn, bool tt)
        //    {
        //        this.cateid = id;
        //        this.nhadat = nd;
        //        this.diendan = dd;
        //        this.ngonngu = nn;
        //        this.tintuc = tt;
        //    }
        //}
        //#endregion//end khai bao tham so

        //#region Truy cap du lieu
        //private void DataPortal_Fetch(FilterCriteriaGetCategoryBO_ByType criteria)
        //{
        //    bool cancel = false;
        //    OnFetching(criteria, ref cancel);
        //    if (cancel) return;

        //    using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
        //                .GetManager(Database.HousingInfoConnection))
        //    {
        //        var data = mgr.DataContext.Categories
        //                .Single(r => r.CategoryID == criteria.Value);

        //        OnMemberLoading(data);
        //        LoadProperty<int>(CategoryIDProperty, data.CategoryID);
        //        LoadProperty<string>(CategoryNameProperty, data.CategoryName);
        //        LoadProperty<bool>(IsHousingCategoryProperty, data.IsHousingCategory);
        //        LoadProperty<bool>(IsTopicForumProperty, data.IsTopicForum);
        //        LoadProperty<bool>(IsLanguageProperty, data.IsLanguage);
        //        LoadProperty<bool>(IsNewsCategoryProperty, data.IsNewsCategory);
        //        LoadProperty<bool>(IsActiveProperty, data.IsActive);
        //        //OnMemberLoaded();

        //        ValidationRules.CheckRules();
        //    }//using

        //    //OnFetched();
        //}
        //#endregion//end truy cap

        //#endregion //End Trang Admin Danh muc


	}
}
